`
https://leetcode.cn/problems/simplify-path/
`

/**
 * @param {string} path
 * @return {string}
 */
var simplifyPath = function (path) {
  const parts = path.split('/')
  const stk = []
  for (const part of parts) {
    if (part === '' || part === '.') {
      continue
    }
    if (part === '..') {
      if (stk.length) stk.pop()
      continue
    }
    stk.push(part)
  }

  return '/' + stk.join('/')
};